//
//  SportsGuideCell.m
//  SHHCPhone
//
//  Created by sheng long on 14-6-30.
//  Copyright (c) 2014年 sheng long. All rights reserved.
//

#import "SportsGuideCell.h"

@interface SportsGuideCell()
{
    UIView *bgView;
    
    UILabel *titleLabel;
    UILabel *numberLabel;
    UIImageView *flagImage;
}
@end

@implementation SportsGuideCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier size:(CGSize)size
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        bgView = [[UIView alloc] initWithFrame:CGRectMake(size.width-260-12, 12, 260, 62)];
        [bgView setBackgroundColor:GET_COLOR(@"f5f5f5")];
        [self.contentView addSubview:bgView];
        
//        UIImageView *roundImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"菜品名称页-圆圈icon"]];
//        [roundImage sizeToFit];
//        [roundImage setCenter:CGPointMake(bgView.frame.origin.x-5-roundImage.frame.size.width/2+0.5, bgView.frame.origin.y+5+roundImage.frame.size.height/2)];
//        [self addSubview:roundImage];
        
        UIView *roundImage = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 14, 14)];
        [roundImage setBackgroundColor:GET_COLOR(@"f2f2f2")];
        [roundImage.layer setCornerRadius:roundImage.frame.size.width/2];
        [roundImage setCenter:CGPointMake(bgView.frame.origin.x-5-roundImage.frame.size.width/2+0.5, bgView.frame.origin.y+5+roundImage.frame.size.height/2)];
        [self addSubview:roundImage];
        
        titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [titleLabel setBackgroundColor:[UIColor clearColor]];
        [titleLabel setFont:[UIFont boldSystemFontOfSize:15]];
        [titleLabel setTextColor:GET_COLOR(@"fb98bc")];
        [bgView addSubview:titleLabel];
        
        numberLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [numberLabel setBackgroundColor:[UIColor clearColor]];
        [numberLabel setFont:[UIFont systemFontOfSize:15]];
        [numberLabel setTextColor:GET_COLOR(@"3d3d3d")];
        [bgView addSubview:numberLabel];
        
        flagImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        [bgView addSubview:flagImage];
    }
    return self;
}

-(void)setContent:(SportsGuideInfo*)info
{
    [flagImage setImage:[UIImage imageNamed:info.icon]];
    [flagImage sizeToFit];
    [flagImage setCenter:CGPointMake(bgView.frame.size.width-12-flagImage.frame.size.width/2, bgView.frame.size.height/2)];
    
    [titleLabel setFrame:CGRectMake(20, 3, flagImage.frame.origin.x-20, bgView.frame.size.height/2)];
    [titleLabel setText:info.sport];
    
    [numberLabel setFrame:CGRectMake(20, bgView.frame.size.height/2-3, flagImage.frame.origin.x-20, bgView.frame.size.height/2)];
    [numberLabel setText:info.intensity];

//    NSString *content = [NSString stringWithFormat:@"%@\n%@",info.title,info.number];
//    NSRange range = [content rangeOfString:info.number];
//    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:content];
//    [text addAttribute:NSForegroundColorAttributeName value:GET_COLOR(@"3d3d3d") range:range];
//    [titleLabel setFrame:CGRectMake(20, 0, flagImage.frame.origin.x-20, bgView.frame.size.height/2)];
//    [titleLabel setNumberOfLines:0];
//    [titleLabel setAttributedText:info.title];

}

@end
